<template>
  <el-checkbox-group v-model="formData[data.field]" @change="searchFun" :disabled="data.disabled">
    <el-checkbox v-for="item in data.choices" :key="item.key" :label="item.key">
      <el-tooltip :content="item.value" placement="top" effect="light">
        {{ item.value }}
      </el-tooltip>
    </el-checkbox>
  </el-checkbox-group>
</template>

<script lang="ts">
import { defineComponent, computed } from 'vue'
import { baseForm } from '@/common/mixins/index'

export default defineComponent({
  name: 'BaseCheckbox',
  props: {
    form: {
      type: Object,
      default: () => ({})
    },
    data: {
      type: Object,
      default: () => ({})
    }
  },
  emits: ['onSearchFun', 'update:form'],
  setup(props, { emit }) {
    const formData = computed({
      get: () => props.form,
      set: (val) => emit('update:form', val)
    })

    const searchFun = () => {
      baseForm.searchFun(emit)
    }
    return { searchFun, formData }
  }
})
</script>

<style lang="stylus" scoped></style>
